import axios from '../http';
import { HttpResponse } from '@/types/HttpResponse';
/**
 * @interface loginParams -登录参数
 * @property {string} username -用户名，可能是手机号，也可能是身份证号
 * @property {string} password -用户密码
 */
export interface LoginParams {
  username: string;
  password: string;
}
/**
 * @interface RegisterParams -注册参数
 * @property {string} username -姓名
 * @property {string} ID -身份证号
 * @property {string} phoneNumber -手机号
 * @property {string} verificationCode -验证码
 * @property {string} password1 -密码
 * @property {string} password2 -确认密码 
 */
export interface RegisterParams {
  username: string;
  ID: string;
  phoneNumber: string;
  verificationCode: string;
  password1: string;
  password2: string;
}
/**
 * @interface FindPassword1Params -找回密码第一部分参数
 * @property {string} username -姓名
 * @property {string} ID -身份证号
 */
export interface FindPassword1Params {
  username: string;
  ID: string;
}
/**
 * @interface FindPassword2Params -找回密码第二部分参数
 * @property {string} phoneNumber -手机号
 * @property {string} verificationCode -验证码
 */
 export interface FindPassword2Params {
  phoneNumber: string;
  verificationCode: string;
}
/**
 * @interface ChangePasswordParams -更改密码参数
 * @property {string} phoneNumber -电话号码
 * @property {string} Password1 -新密码
 * @property {string} Password2 -确认新密码，值和新密码一样
 */
 export interface ChangePasswordParams {
  phoneNumber: string;
  newPassword1: string;
  newPassword2: string;
}
/**
 * @interface PassengerInf -购买机票的乘客信息
 * @property {string} name -乘客姓名
 * @property {string} ID -乘客身份证号
 * @property {boolean} isChild -是否是孩子
 * @property {boolean} insurance1 -乘客是否购买航空综合险
 * @property {boolean} insurance2 -乘客是否购买无忧退票险
 */
export interface PassengerInf {
  name: string;
  ID: string;
  isChild: boolean,
  insurance1: boolean;
  insurance2: boolean;
}
//封装User类型的接口方法
export class UserService {
  /**
   * @description 查询User的信息
   * @param {number} teamId - 所要查询的团队ID
   * @return {HttpResponse} result
   */

  static async login1(params: LoginParams): Promise<HttpResponse> {
    return axios('/Login', {
      method: 'post',
      responseType: 'json',
      params: params,
    });
  }

  static async login2(params: LoginParams): Promise<HttpResponse> {
    return axios('/adminLogin', {
      method: 'post',
      responseType: 'json',
      params: params,
    });
  }

  static async register(params: RegisterParams): Promise<HttpResponse> {
    return axios('/register', {
      method: 'post',
      responseType: 'json',
      params: params,
      
    });
  }
  static async getCode(params: object): Promise<HttpResponse> {
    return axios('/phoneCode', {
      method: 'post',
      responseType: 'json',
      params: params,
      
    });
  }


  static async findPassword1(params: FindPassword1Params): Promise<HttpResponse> {
    return axios('/getMyPhone', {
      method: 'post',
      responseType: 'json',
      params: params,
    });
  }
  static async findPassword2(params: FindPassword2Params): Promise<HttpResponse> {
    return axios('/passwordCode', {
      method: 'post',
      responseType: 'json',
      params: params,
    });
  }
  static async changePassword(params: ChangePasswordParams): Promise<HttpResponse> {
    return axios('/newPassword', {
      method: 'post',
      responseType: 'json',
      params: params,
    });
  }
}
